// Define the diferent types of link
var CHANNELLINK = 1;
var ELEMENTLINK = 2;
var SITELINK    = 3;
var EXTERNALURL = 4;
var MEDIALINK   = 5;
var INTERNALLINK = 13;

// define the diferent types of target
var SELFTARGET				= 1;
var TOPTARGET					= 2;
var NEWTARGET					= 3;
var NAMEDWINDOWTARGET	= 4;
var NAMEDFRAMETARGET	=	5;
var NEWSIZEDTARGET		= 6;
var NULLTARGET				= 7;

// This function activates the link
function dukopen(baseURL, linkData, linkType, targetType, targetName, width, height){
	// check parameters
	if (isNaN(linkType) || linkType > 13 || linkType < 1){
	  alert("Invalid Link Type passed to dukopen(): " + linkType);
		return;
	}
	if(isNaN(targetType) || targetType > 7 || targetType < 1){
		alert("Invalid Target Type passed to dukopen(): " + targetType);
	}
	
	var linkString="";
	switch (linkType){
		case CHANNELLINK : 
			linkString = baseURL + "index.cfm?page=" + linkData;
			break;
		
		case ELEMENTLINK : 
			var dataArray=linkData.split("_");
			var channel=dataArray[0];
			var element=dataArray[1];
			linkString = baseURL + "index.cfm?page=" + channel +"&element=" + element ;
			break
		
		case SITELINK : 
			linkString = baseURL;
			break;
		
		case EXTERNALURL : 
			linkString = linkData;
			break
		
		case MEDIALINK : 
			linkString = "" + baseURL +"media/"+ linkData;
			break
				
	}
	
	switch (targetType){
		case SELFTARGET : 
			window.location = linkString;
			break;
		
		case TOPTARGET : 
			window.top.location = linkstring;
			break;		
		
		case NEWTARGET : 
			window.open(linkString,"_new","scrollbars=auto");
			break;		
		
		case NAMEDWINDOWTARGET : 
			window.open(linkString,targetName,"scrollbars=auto");
			break;		
		
		case NAMEDFRAMETARGET : 
			window.top.frames[targetName].location = linkString;
			break;		
		
		case NEWSIZEDTARGET : 
			window.open(linkString,targetName,"HEIGHT="+height+", WIDTH="+width + ", scrollbars=1");
			break;		
		
		case NULLTARGET : 
			return;
		
	}
}